/** 
 * Project Name:kaka
 * File Name:WeChatTestAction.java 
 * Package Name:com.luoran.kaka 
 * Date:2018年12月7日下午6:08:14 
 * Copyright (c) 2018, Luoran, Inc. All Rights Reserved.
 * 
 */  
package com.luoran.kaka.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;

/** 
 * @author ghl 
 * @since JDK 1.8
 * ClassName: WeChatTestAction
 * date: 2018年12月7日 下午6:08:14
 *	
 */
@Controller
@RequestMapping("/wechat")
public class WeChatTestAction {

	@RequestMapping(value="/testButton")
	@ResponseBody
    public JSONObject buttonTest(String username, String password, HttpServletResponse response) throws ServletException, IOException{
        response.setContentType("text/html;charset=utf-8");
        /* 设置响应头允许ajax跨域访问 */  
        response.setHeader("Access-Control-Allow-Origin", "*");  
        /* 星号表示所有的异域请求都可以接受， */  
        response.setHeader("Access-Control-Allow-Methods", "GET,POST");  
        System.out.println("username="+username+" ,password="+password);
        //返回值给微信小程序
//        Writer out = response.getWriter(); 
//        out.write("进入后台");
//        out.flush(); 
        JSONObject obj = new JSONObject();
        obj.put("flag", true);
        obj.put("username", username);
        obj.put("password", password);
        return obj;
    }
}
